/*****************************************************************************/
/**
*
* @file uiicps.h
*
* Header file for uiic.c.
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver   Who    Date   	Changes
* ----- ---- ---------- -------------------------------------------------------
* 0.01  abu  05/20/2019 Created
* </pre>
*
*------------------------------------------------------------------------------
* Author: abu	E-mail:	abu_liu@aliyun.com
*				Blog:	https://blog.csdn.net/ClamerKorallen
*				Gitee:	https://gitee.com/abu_liu
*------------------------------------------------------------------------------
*
******************************************************************************/
#ifndef UIICPS_H		/* prevent circular inclusions */
#define UIICPS_H		/* by using protection macros */

#ifdef __cplusplus
	extern "C" {
#endif

/***************************** Include Files *********************************/
#include "xil_types.h"
#include "xiicps.h"
#include "debug.h"

/************************** Constant Definitions *****************************/
#define UIIC_SCLK_400KHZ	400000	//iic clock is 384.6khz in fact when set to 400khz
#define UIIC_SCLK_100KHZ	100000	//iic clock is 90khz in fact when set to 100khz
#define UIIC0_INTR_ID		XPAR_XIICPS_0_INTR		//interrupt id
#define UIIC1_INTR_ID		XPAR_XIICPS_1_INTR		//interrupt id

//iic0 device
#ifdef	XPAR_PS7_I2C_0_DEVICE_ID
#define	UIIC0_DEV_ID		XPAR_PS7_I2C_0_DEVICE_ID	//device ID
#endif

//iic1 device
#ifdef	XPAR_PS7_I2C_1_DEVICE_ID
#define	UIIC1_DEV_ID		XPAR_PS7_I2C_1_DEVICE_ID	//device ID
#endif

/************************** Variable definitions *****************************/
XIicPs uiic0ps;

volatile u32 SendComplete;
volatile u32 RecvComplete;
volatile u32 TotalErrorCount;

typedef struct {
	volatile u32 SendComplete;
	volatile u32 RecvComplete;
	volatile u32 TotalErrorCount;
}uIicTransStatus;

uIicTransStatus uIic0TransStatus;
uIicTransStatus uIic1TransStatus;

/*************************** Hardware constants ******************************/

/************************** Function Prototypes ******************************/
void uIicPsInit(XIicPs *Instance_ptr, u32 DeviceId);
void uIicPsIntrSetup(XIicPs *IicPsPtr);
void uIic0PsHandler(void *CallBackRef, u32 Event);
void uIic1PsHandler(void *CallBackRef, u32 Event);

#ifdef __cplusplus
}
#endif

#endif